# -*- coding: utf-8 -*-


import unittest
import sys
import os
import time

# 添加执行环境
file_exec_path = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
sys.path.insert(0, file_exec_path)

os.environ["framework_env"] = file_exec_path
# os.environ.setdefault("FRAMEWORK_SETTINGS_MODULE", "framework_strategy.gopy.settings")

from framework_strategy.gopy.trader.engine import EmailEngine, MiddlewareBase, MainEngine, EventEngine  # NOQA
from framework_strategy.gopy.base.api import API, Event  # NOQA
from framework_strategy.gopy.gateways.object import *  # NOQA
from framework_strategy.gopy.gateways.xt.xt_api import XTGateway  # NOQA
# from framework_strategy.gopy.middleware.templatemiddleware import TemplateMiddleware


def init_engine():
    event_engine = EventEngine()
    main_engine = MainEngine(event_engine=event_engine)

    return event_engine, main_engine

def request_test():
    print("-----request_test----")


class TestMiddleware(unittest.TestCase):
    """  """

    @unittest.skip
    def test_init(self):
        event, main = init_engine()
        mid = MiddlewareBase(main, event)
        mid.load_middleware()


    def test_exec_middleware(self):

        event, main = init_engine()
        MiddlewareBase(main, event)

        main.prepare(request_test, 1, 2, a=3)

    

if __name__ == "__main__":
    unittest.main()
    pass
